package com.sky.myapplication;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.sky.myapplication.java.activity.AnotherActivity;
import com.sky.myapplication.java.activity.FragmentActivity;
import com.sky.myapplication.java.activity.GroupViewActivity;
import com.sky.myapplication.java.activity.ServiceActivity;
import com.sky.myapplication.java.activity.ViewActivity;
//import com.sky.myapplication.kotlin.kotlinActivity.ContentProviderKotlinActivity;
import com.sky.myapplication.kotlin.kotlinActivity.FileManagerKotlinActivity;
import com.sky.myapplication.kotlin.kotlinActivity.PractiveCodeKotlinActivity;
import com.sky.myapplication.kotlin.kotlinActivity.RecycleViewKotlinActivity;
import com.sky.myapplication.kotlin.kotlinActivity.SQLiteKotlinActivity;
import com.sky.myapplication.kotlin.kotlinActivity.VideoKotlinActivity;
import com.sky.myapplication.kotlin.kotlinActivity.ViewPageKotlinActivity;
import com.sky.myapplication.kotlin.kotlinActivity.ViewPageFragmentKotlinActivity;
import com.sky.myapplication.kotlin.kotlinActivity.FileSteamKotlinActivity;

import java.util.ArrayList;
import java.util.Arrays;

/**
 *  Created by ruolan
 *  Time 2021/6/18
 *  Desc 跳转的主页
 *
 *  AndroidStudio不需要上传的文件
 *  -- .idea 文件夹，此文件夹是用来保存开发工具的设置信息。
 * -- .gradle 文件夹，此文件夹是用来保存gradle的依赖信息。
 * -- build 文件夹，build文件夹是用来保存编译后的文件目录。
 * -- .iml 文件，是用来保存开发工具信息的。
 * -- local.properties 文件，是用来保存项目依赖信息。
 */
public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(R.style.Theme_MyApplication);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btn_kotlin_code = findViewById(R.id.btn_kotlin_code);
        Button btn_activity_lifecycle = findViewById(R.id.btn_activity_lifecycle);
        Button main_service = findViewById(R.id.main_service);
        Button main_fragment = findViewById(R.id.main_fragment);
        Button main_recycle_view = findViewById(R.id.main_recycle_view);
        Button main_view_page = findViewById(R.id.main_view_page);
        Button main_view_page_fragment = findViewById(R.id.main_view_page_fragment);
        Button main_input_file = findViewById(R.id.main_input_file);
        Button main_input_sqlite = findViewById(R.id.main_input_sqlite);
        Button main_content_provider = findViewById(R.id.main_content_provider);
        Button main_draw_view = findViewById(R.id.main_draw_view);
        Button main_group_view = findViewById(R.id.main_group_view);
        Button main_dialog = findViewById(R.id.main_dialog);
        Button main_file = findViewById(R.id.main_file);
        Button main_flutter = findViewById(R.id.main_flutter);
        Button main_video = findViewById(R.id.main_video);

        btn_kotlin_code.setOnClickListener(this);
        btn_activity_lifecycle.setOnClickListener(this);
        main_service.setOnClickListener(this);
        main_fragment.setOnClickListener(this);
        main_recycle_view.setOnClickListener(this);
        main_view_page.setOnClickListener(this);
        main_view_page_fragment.setOnClickListener(this);
        main_input_file.setOnClickListener(this);
        main_input_sqlite.setOnClickListener(this);
        main_content_provider.setOnClickListener(this);
        main_draw_view.setOnClickListener(this);
        main_group_view.setOnClickListener(this);
        main_dialog.setOnClickListener(this);
        main_file.setOnClickListener(this);
        main_flutter.setOnClickListener(this);
        main_video.setOnClickListener(this);

//        List<DistrictBean> list = new ArrayList<>();
//        DistrictBean districtBean = new DistrictBean(0, "aaaaaaa", "", "", 0, "bbbbbb", 0);
//
//        list.add(districtBean);
//        list.add(districtBean);
//        list.add(districtBean);
//        list.add(districtBean);
//
//        BusinessSelectDialog businessSelectDialog = new BusinessSelectDialog(this, list);
//        businessSelectDialog.show(getSupportFragmentManager(), "");
//        businessSelectDialog.setItemClick(new BusinessSelectDialog.ItemClick() {
//            @Override
//            public void onItemClick(@NonNull DistrictBean bean) {
//                if (bean != null){
//                    businessSelectDialog.dismiss();
//                }
//            }
//        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1 && resultCode == 1){
            Toast.makeText(this, data.getIntExtra("a", 1)+"", Toast.LENGTH_LONG).show();
        }
    }


    @Override
    public void onClick(View view) {
        int viewId = view.getId();
        if (viewId == R.id.btn_activity_lifecycle) {
            Intent intent = new Intent(this, AnotherActivity.class);
            startActivity(intent);

//            ClipboardManager clip = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
//            if (clip != null) {
//                clip.setPrimaryClip(ClipData.newPlainText(null, "123")); // 复制
//            }
        } else if (viewId == R.id.main_service) {
            Intent intentService = new Intent(this, ServiceActivity.class);
            startActivityForResult(intentService, 1);
        } else if (viewId == R.id.main_fragment) {
            Intent intentFragment = new Intent(this, FragmentActivity.class);
            startActivity(intentFragment);
        } else if (viewId == R.id.main_recycle_view) {
            Intent intentKotlinRecycle = new Intent(this, RecycleViewKotlinActivity.class);
            startActivity(intentKotlinRecycle);
        } else if (viewId == R.id.main_view_page) {
            Intent intentViewPage = new Intent(this, ViewPageKotlinActivity.class);
            startActivity(intentViewPage);
        } else if (viewId == R.id.main_view_page_fragment) {
            Intent intentViewPage = new Intent(this, ViewPageFragmentKotlinActivity.class);
            startActivity(intentViewPage);
        } else if (viewId == R.id.main_input_file) {
            Intent intentViewPage = new Intent(this, FileSteamKotlinActivity.class);
            startActivity(intentViewPage);
        } else if (viewId == R.id.main_input_sqlite) {
            Intent intentSQLite = new Intent(this, SQLiteKotlinActivity.class);
            startActivity(intentSQLite);
        } else if (viewId == R.id.main_content_provider) {
//            Intent intentSQLite = new Intent(this, ContentProviderKotlinActivity.class);
//            startActivity(intentSQLite);
        } else if (viewId == R.id.main_draw_view) {
            Intent intentDrawView = new Intent(this, ViewActivity.class);
            startActivity(intentDrawView);
        } else if (viewId == R.id.main_group_view) {
            Intent intentDrawView = new Intent(this, GroupViewActivity.class);
            startActivity(intentDrawView);
        } else if (viewId == R.id.main_dialog){

        } else if (viewId == R.id.main_file){
            Intent intentFile = new Intent(this, FileManagerKotlinActivity.class);
            startActivity(intentFile);
        } else if (viewId == R.id.main_flutter){

        } else if (viewId == R.id.btn_kotlin_code){
            jumpActivity(PractiveCodeKotlinActivity.class);
        } else if (viewId == R.id.main_video){
            jumpActivity(VideoKotlinActivity.class);
        }
    }

    private void jumpActivity(Class<?> cls){
        Intent intent = new Intent(this, cls);
        startActivity(intent);
    }
}